<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<c:set var="user" value="${fns:getUser()}" />
<html>
<head>
	<title>修改密码</title>
	<%@include file="/WEB-INF/views/include/head.jsp" %>
	<script type="text/javascript">
	var myValidate;
		$(document).ready(function() {
			var message='${message}';
			$("#oldPassword").focus();
			myValidate=$("#inputForm").validate({
				messages: {
					confirmNewPassword: {equalTo: "输入与上面相同的密码"}
				},
				submitHandler: function(form){
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$(element).closest( "form" )
					.find( "span[for='" + element.attr( "name" ) + "']" ).html(error);
				}
			});
		});
		
		function savePwdForm(){
		
			if(myValidate.form()){
				$.ajax({
					url:'${ctxAdmin}/sys/user/modifyPersonPwd',
					type:'post',
					dataType:'text',
					data:$('#inputForm').serialize(),
					success:function(res){
						if('success'==res){
							layer.msg("修改成功！");
							 $("input[type=password]").val("");  
						}else{
							layer.msg(res);
							return;
						}
					},
					error: function(XMLHttpRequest, textStatus, errorThrown) {
					    layer.msg("操作失败，请联系管理员！");
					}
				});
			}
		}
		
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
       	<li><a href="${ctxAdmin}/sys/user/info">个人信息</a></li>
		<li class="active"><a href="${ctxAdmin}/sys/user/modifyPwd">修改密码</a></li>
	</ul><br/>
	<form:form id="inputForm" class="form-horizontal">
		<input type="submit" id="submitBtn" style="display: none;"/>	
		<%-- <sys:message content="${message}"/> --%>
		<div class="form-group">
			<label class="col-sm-2 control-label">旧密码:</label>
			<div class="col-sm-4">
				<input id="oldPassword" name="oldPassword" type="password" value="" maxlength="50" minlength="3" class="required form-control"/>
				
			</div>
			<div class="col-sm-2">
				<span for="oldPassword"></span>
				<font color="red">*</font> 
			</div>
		</div>
		<div class="hr-line-dashed"></div>
		<div class="form-group">
			<label class="col-sm-2 control-label">新密码:</label>
			<div class="col-sm-4">
				<input id="newPassword" name="newPassword" type="password" value="" maxlength="16" minlength="6" class="required form-control"/>
			</div>
			<div class="col-sm-2">
				<span for="newPassword"></span>
				<font color="red">*</font> 
			</div>
		</div>
		<div class="hr-line-dashed"></div>
		<div class="form-group">
			<label class="col-sm-2 control-label">确认新密码:</label>
			<div class="col-sm-4">
				<input id="confirmNewPassword" name="confirmNewPassword" type="password" value="" maxlength="50" minlength="3" class="required form-control" equalTo="#newPassword"/>
			</div>
			<div class="col-sm-2">
				<span for="confirmNewPassword"></span>
				<font color="red">*</font> 
			</div>
		</div>
		<div class="hr-line-dashed"></div>
		<div class="form-group">
			<div class="col-sm-2 col-sm-offset-3">
			<input id="btnSubmit" class="btn btn-success" type="button" value="保 存" onclick="savePwdForm()"/>
			</div>
		</div>
	</form:form>
</body>
</html>